import request from '@/utils/request'

/**
 * 上传单个文件
 * @param {File} file - 文件对象
 * @param {Function} onProgress - 上传进度回调
 * @returns {Promise}
 */
export function uploadFile(file, onProgress) {
  const formData = new FormData()
  formData.append('file', file)
  return request.upload('/api/uploadFile', formData, onProgress)
}

/**
 * 上传图片
 * @param {File} file - 图片文件
 * @param {Function} onProgress - 上传进度回调
 * @returns {Promise}
 */
export function uploadImage(file, onProgress) {
  const formData = new FormData()
  formData.append('file', file)
  return request.upload('/api/minio/uploadImages', formData, onProgress)
}


/**
 * 删除文件
 * @param {string} url - 文件URL
 * @returns {Promise}
 */
export function deleteFile(url) {
  return request.delete('/api/minio/delete', { fileName: url })
}
